package com.bie.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.woke.dao.ChouJiang;
import com.woke.dao.Customer;
import com.woke.dao.User;

public class ShuJuAction implements Action, ServletRequestAware, ServletResponseAware, ServletContextAware {
	private HttpServletRequest request;
	private HttpServletResponse responese;
	private HttpSession session;
	private ServletContext application;

	public HttpServletRequest getRequest() {
		return request;
	}



	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}



	public HttpServletResponse getResponese() {
		return responese;
	}



	public void setResponese(HttpServletResponse responese) {
		this.responese = responese;
	}



	public HttpSession getSession() {
		return session;
	}



	public void setSession(HttpSession session) {
		this.session = session;
	}



	public ServletContext getApplication() {
		return application;
	}



	public void setApplication(ServletContext application) {
		this.application = application;
	}



	public  void getnum1() throws Exception {
		Calendar now = Calendar.getInstance();  
        Date d = new Date();  
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
        String dateNowStr = sdf.format(d); 
		
        Date date=new Date();
		//Calendar calendar =new GregorianCalendar();
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(calendar.DATE, -1);
		date = calendar.getTime();
		SimpleDateFormat format= new SimpleDateFormat("yyyy-MM-dd");
		String dateString = format.format(date);
        
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cal = Calendar.getInstance(); 
		cal.setTime(new Date()); 
		cal.add(Calendar.DAY_OF_YEAR, 1);
		String nextday=sf.format(cal.getTime());
        
		CeShiTime ce=new CeShiTime();
		Date beginweek=ce.getBeginDayOfLastWeek();
		Date endweek=ce.getEndDayOfLastWeek();
		Date beginmonth=ce.getBeginDayOfLastMonth();
		Date endmonth=ce.getEndDayOfLastMonth();
		int nowyear=ce.getNowYear();
		Date endday=ce.getEndDayOfYesterDay();
		
		String sql1="select * from user ";
		String sql2="select * from user where createtime>='"+endday+"' and createtime<'"+dateNowStr+"'";
		String sql3="select * from user where createtime>='"+dateNowStr+"' and createtime<'"+nextday+"'";
		String sql4="select * from user where createtime>='"+beginweek+"' and createtime<'"+endweek+"'";
		String sql5="select * from user where createtime>='"+beginmonth+"' and createtime<'"+endmonth+"'";
		String sql6="select * from user where createtime>='"+(nowyear+"-08-01")+"' and createtime<'"+(nowyear+"-08-31")+"'";
		
		String sql11="select * from customer";
		String sql7="select * from customer where cuscreatetime>='"+endday+"' and cuscreatetime<'"+dateNowStr+"'";
		String sql8="select * from customer where cuscreatetime>='"+dateNowStr+"' and cuscreatetime<'"+nextday+"'";
		String sql9="select * from customer where cuscreatetime>='"+beginweek+"' and cuscreatetime<'"+endweek+"'";
		String sql10="select * from customer where cuscreatetime>='"+beginmonth+"' and cuscreatetime<'"+endmonth+"'";
		
		String sql17="select * from choujiang";
		String sql18="select * from choujiang where cjcreatetime>='"+endday+"' and cjcreatetime<'"+dateNowStr+"'";
		
		String sql19="select * from choujiang where cjcreatetime>='"+dateNowStr+"' and cjcreatetime<'"+nextday+"'";
		String sql20="select * from choujiang where cjcreatetime>='"+beginweek+"' and cjcreatetime<'"+endweek+"'";
		String sql21="select * from choujiang where cjcreatetime>='"+beginmonth+"' and cjcreatetime<'"+endmonth+"'";
		
		
		List<User> list1=User.getData(sql1);
		List<User> list2 = User.getData(sql2);
		List<User> list3 = User.getData(sql3);
		List<User> list4 = User.getData(sql4);
		List<User> list5 = User.getData(sql5);
		List<User> list6 = User.getData(sql6);
		List<Customer> list7 = Customer.getData(sql7);
		List<Customer> list8 = Customer.getData(sql8);
		List<Customer> list9 = Customer.getData(sql9);
		List<Customer> list10 = Customer.getData(sql10);
		List<Customer> list11 = Customer.getData(sql11);
		
		List<ChouJiang> list12 = ChouJiang.getData(sql17);
		List<ChouJiang> list13 = ChouJiang.getData(sql18);
		List<ChouJiang> list14 = ChouJiang.getData(sql19);
		List<ChouJiang> list15 = ChouJiang.getData(sql20);
		List<ChouJiang> list16 = ChouJiang.getData(sql21);
		
			int num=list1.size();
			int num2=list2.size();
			int num3=list3.size();
			int num4=list4.size();
			int num5=list5.size();
			int num6=list6.size();
			int num7=list7.size();
			int num8=list8.size();
			int num9=list9.size();
			int num10=list10.size();
			int num11=list11.size();
			int num12=list12.size();
			int num13=list13.size();
			int num14=list14.size();
			int num15=list15.size();
			int num16=list16.size();
			ActionContext actionContext = ActionContext.getContext();
			Map<String, Object> session = actionContext.getSession(); 
			session.put("num", num);
			session.put("num2", num2);
			session.put("num3", num3);
			session.put("num4", num4);
			session.put("num5", num5);
			session.put("num6", num6);
			session.put("num7", num7);
			session.put("num8", num8);
			session.put("num9", num9);
			session.put("num10", num10);
			session.put("num11", num11);
			session.put("num12", num12);
			session.put("num13", num13);
			session.put("num14", num14);
			session.put("num15", num15);
			session.put("num16", num16);
	
}
	
	
	public void getMonthNum() {
		CeShiTime ce=new CeShiTime();
		int nowyear=ce.getNowYear();
		String sql="select * from user where createtime>='"+(nowyear+"-01-01")+"' and createtime<'"+(nowyear+"-01-31")+"'";
		String sql1="select * from user where createtime>='"+(nowyear+"-02-01")+"' and createtime<'"+(nowyear+"-02-29")+"'";
		String sql2="select * from user where createtime>='"+(nowyear+"-03-01")+"' and createtime<'"+(nowyear+"-03-31")+"'";
		String sql3="select * from user where createtime>='"+(nowyear+"-04-01")+"' and createtime<'"+(nowyear+"-04-31")+"'";
		String sql4="select * from user where createtime>='"+(nowyear+"-05-01")+"' and createtime<'"+(nowyear+"-05-31")+"'";
		String sql5="select * from user where createtime>='"+(nowyear+"-06-01")+"' and createtime<'"+(nowyear+"-06-31")+"'";
		String sql6="select * from user where createtime>='"+(nowyear+"-07-01")+"' and createtime<'"+(nowyear+"-07-31")+"'";
		String sql7="select * from user where createtime>='"+(nowyear+"-08-01")+"' and createtime<'"+(nowyear+"-08-31")+"'";
		String sql8="select * from user where createtime>='"+(nowyear+"-09-01")+"' and createtime<'"+(nowyear+"-09-31")+"'";
		String sql9="select * from user where createtime>='"+(nowyear+"-10-01")+"' and createtime<'"+(nowyear+"-10-31")+"'";
		String sql10="select * from user where createtime>='"+(nowyear+"-11-01")+"' and createtime<'"+(nowyear+"-11-31")+"'";
		String sql11="select * from user where createtime>='"+(nowyear+"-12-01")+"' and createtime<'"+(nowyear+"-12-31")+"'";
		List<User> list=User.getData(sql);
		List<User> list1=User.getData(sql1);
		List<User> list2=User.getData(sql2);
		List<User> list3=User.getData(sql3);
		List<User> list4=User.getData(sql4);
		List<User> list5=User.getData(sql5);
		List<User> list6=User.getData(sql6);
		List<User> list7=User.getData(sql7);
		List<User> list8=User.getData(sql8);
		List<User> list9=User.getData(sql9);
		List<User> list10=User.getData(sql10);
		List<User> list11=User.getData(sql11);
		
		ActionContext actionContext = ActionContext.getContext();
		Map<String, Object> session = actionContext.getSession(); 
		int n1=list.size();
		int n2=list1.size();
		int n3=list2.size();
		int n4=list3.size();
		int n5=list4.size();
		int n6=list5.size();
		int n7=list6.size();
		int n8=list7.size();
		int n9=list8.size();
		int n10=list9.size();
		int n11=list10.size();
		int n12=list11.size();
		session.put("n1", n1);
		session.put("n2", n2);
		session.put("n3", n3);
		session.put("n4", n4);
		session.put("n5", n5);
		session.put("n6", n6);
		session.put("n7", n7);
		session.put("n8", n8);
		session.put("n9", n9);
		session.put("n10", n10);
		session.put("n11", n11);
		session.put("n12", n12);
		
	}
	
	public void getMonthNum1() {
		CeShiTime ce=new CeShiTime();
		int nowyear=ce.getNowYear();
		String sql="select * from customer where cuscreatetime>='"+(nowyear+"-01-01")+"' and cuscreatetime<'"+(nowyear+"-01-31")+"'";
		String sql1="select * from customer where cuscreatetime>='"+(nowyear+"-02-01")+"' and cuscreatetime<'"+(nowyear+"-02-29")+"'";
		String sql2="select * from customer where cuscreatetime>='"+(nowyear+"-03-01")+"' and cuscreatetime<'"+(nowyear+"-03-31")+"'";
		String sql3="select * from customer where cuscreatetime>='"+(nowyear+"-04-01")+"' and cuscreatetime<'"+(nowyear+"-04-31")+"'";
		String sql4="select * from customer where cuscreatetime>='"+(nowyear+"-05-01")+"' and cuscreatetime<'"+(nowyear+"-05-31")+"'";
		String sql5="select * from customer where cuscreatetime>='"+(nowyear+"-06-01")+"' and cuscreatetime<'"+(nowyear+"-06-31")+"'";
		String sql6="select * from customer where cuscreatetime>='"+(nowyear+"-07-01")+"' and cuscreatetime<'"+(nowyear+"-07-31")+"'";
		String sql7="select * from customer where cuscreatetime>='"+(nowyear+"-08-01")+"' and cuscreatetime<'"+(nowyear+"-08-31")+"'";
		String sql8="select * from customer where cuscreatetime>='"+(nowyear+"-09-01")+"' and cuscreatetime<'"+(nowyear+"-09-31")+"'";
		String sql9="select * from customer where cuscreatetime>='"+(nowyear+"-10-01")+"' and cuscreatetime<'"+(nowyear+"-10-31")+"'";
		String sql10="select * from customer where cuscreatetime>='"+(nowyear+"-11-01")+"' and cuscreatetime<'"+(nowyear+"-11-31")+"'";
		String sql11="select * from customer where cuscreatetime>='"+(nowyear+"-12-01")+"' and cuscreatetime<'"+(nowyear+"-12-31")+"'";
		List<Customer> list=Customer.getData(sql);
		List<Customer> list1=Customer.getData(sql1);
		List<Customer> list2=Customer.getData(sql2);
		List<Customer> list3=Customer.getData(sql3);
		List<Customer> list4=Customer.getData(sql4);
		List<Customer> list5=Customer.getData(sql5);
		List<Customer> list6=Customer.getData(sql6);
		List<Customer> list7=Customer.getData(sql7);
		List<Customer> list8=Customer.getData(sql8);
		List<Customer> list9=Customer.getData(sql9);
		List<Customer> list10=Customer.getData(sql10);
		List<Customer> list11=Customer.getData(sql11);
		
		ActionContext actionContext = ActionContext.getContext();
		Map<String, Object> session = actionContext.getSession(); 
		int u1=list.size();
		int u2=list1.size();
		int u3=list2.size();
		int u4=list3.size();
		int u5=list4.size();
		int u6=list5.size();
		int u7=list6.size();
		int u8=list7.size();
		int u9=list8.size();
		int u10=list9.size();
		int u11=list10.size();
		int u12=list11.size();
		session.put("u1", u1);
		session.put("u2", u2);
		session.put("u3", u3);
		session.put("u4", u4);
		session.put("u5", u5);
		session.put("u6", u6);
		session.put("u7", u7);
		session.put("u8", u8);
		session.put("u9", u9);
		session.put("u10", u10);
		session.put("u11", u11);
		session.put("u12", u12);
		
	}
	
	public void getMonthNum2() {
		CeShiTime ce=new CeShiTime();
		int nowyear=ce.getNowYear();
		String sql="select * from choujiang where cjcreatetime>='"+(nowyear+"-01-01")+"' and cjcreatetime<'"+(nowyear+"-01-31")+"'";
		String sql1="select * from choujiang where cjcreatetime>='"+(nowyear+"-02-01")+"' and cjcreatetime<'"+(nowyear+"-02-29")+"'";
		String sql2="select * from choujiang where cjcreatetime>='"+(nowyear+"-03-01")+"' and cjcreatetime<'"+(nowyear+"-03-31")+"'";
		String sql3="select * from choujiang where cjcreatetime>='"+(nowyear+"-04-01")+"' and cjcreatetime<'"+(nowyear+"-04-31")+"'";
		String sql4="select * from choujiang where cjcreatetime>='"+(nowyear+"-05-01")+"' and cjcreatetime<'"+(nowyear+"-05-31")+"'";
		String sql5="select * from choujiang where cjcreatetime>='"+(nowyear+"-06-01")+"' and cjcreatetime<'"+(nowyear+"-06-31")+"'";
		String sql6="select * from choujiang where cjcreatetime>='"+(nowyear+"-07-01")+"' and cjcreatetime<'"+(nowyear+"-07-31")+"'";
		String sql7="select * from choujiang where cjcreatetime>='"+(nowyear+"-08-01")+"' and cjcreatetime<'"+(nowyear+"-08-31")+"'";
		String sql8="select * from choujiang where cjcreatetime>='"+(nowyear+"-09-01")+"' and cjcreatetime<'"+(nowyear+"-09-31")+"'";
		String sql9="select * from choujiang where cjcreatetime>='"+(nowyear+"-10-01")+"' and cjcreatetime<'"+(nowyear+"-10-31")+"'";
		String sql10="select * from choujiang where cjcreatetime>='"+(nowyear+"-11-01")+"' and cjcreatetime<'"+(nowyear+"-11-31")+"'";
		String sql11="select * from choujiang where cjcreatetime>='"+(nowyear+"-12-01")+"' and cjcreatetime<'"+(nowyear+"-12-31")+"'";
		List<ChouJiang> list=ChouJiang.getData(sql);
		List<ChouJiang> list1=ChouJiang.getData(sql1);
		List<ChouJiang> list2=ChouJiang.getData(sql2);
		List<ChouJiang> list3=ChouJiang.getData(sql3);
		List<ChouJiang> list4=ChouJiang.getData(sql4);
		List<ChouJiang> list5=ChouJiang.getData(sql5);
		List<ChouJiang> list6=ChouJiang.getData(sql6);
		List<ChouJiang> list7=ChouJiang.getData(sql7);
		List<ChouJiang> list8=ChouJiang.getData(sql8);
		List<ChouJiang> list9=ChouJiang.getData(sql9);
		List<ChouJiang> list10=ChouJiang.getData(sql10);
		List<ChouJiang> list11=ChouJiang.getData(sql11);
		
		ActionContext actionContext = ActionContext.getContext();
		Map<String, Object> session = actionContext.getSession(); 
		int m1=list.size();
		int m2=list1.size();
		int m3=list2.size();
		int m4=list3.size();
		int m5=list4.size();
		int m6=list5.size();
		int m7=list6.size();
		int m8=list7.size();
		int m9=list8.size();
		int m10=list9.size();
		int m11=list10.size();
		int m12=list11.size();
		session.put("m1", m1);
		session.put("m2", m2);
		session.put("m3", m3);
		session.put("m4", m4);
		session.put("m5", m5);
		session.put("m6", m6);
		session.put("m7", m7);
		session.put("m8", m8);
		session.put("m9", m9);
		session.put("m10", m10);
		session.put("m11", m11);
		session.put("m12", m12);
		
	}



	@Override
	public void setServletContext(ServletContext arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
}